/*
 *  Copyright 2008 Mark Ashworth <javameme@gmail.com>.
 * 
 *  Licensed under the GNU General Public License v3 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.gnu.org/licenses/gpl-3.0.html
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package xperiment.metaphor.persistence.hibernate;

import xperiment.metaphor.model.AbstractSpringJUnit;

/**
 *
 * @author Mark Ashworth <javameme@gmail.com>
 * @version 1.0.0
 */
public class HibernatePersonDaoTest extends AbstractSpringJUnit {
    
    public HibernatePersonDaoTest(String testName) {
        super(testName);
    }            

    public void testPersist() throws Exception {
        logger.info("persist");
        
//        Gender[] genders = new Gender[] {
//            new Gender("MALE"),
//            new Gender("FEMALE")
//        };
//        for(int i = 0; i < genders.length; i++) {
//            genders[i] = (Gender) getDao().persist(genders[i]);
//        }
//        PopulationGroup populationGroup = new PopulationGroup("WHITE");
//        populationGroup = (PopulationGroup) getDao().persist(populationGroup);
//
//        Person person = new Person("Mark", "Ashworth", "MP", "3534345355", new Date(74, 4, 31));
//        person.dateOfBirth(1974, 5, 31);
//        person.setGender(genders[0]);
//        person.setPopulationGroup(populationGroup);
//
//        person = (Person) getDao().persist(person);
//
//        Person another = new Person("Crystal", "Ashworth", "CA");
//        another.dateOfBirth(2001, 5, 28);
//        another.setGender(genders[1]);
//        another.setPopulationGroup(populationGroup);
//
//        another = (Person) getDao().persist(another);
    }
    
    public void testRetrieveXML() throws Exception {
        logger.info("retrieveXML");
        
//        Gender[] genders = new Gender[] {
//            new Gender("MALE"),
//            new Gender("FEMALE")
//        };
//        for(int i = 0; i < genders.length; i++) {
//            genders[i] = (Gender) getDao().persist(genders[i]);
//        }
//        PopulationGroup populationGroup = new PopulationGroup("WHITE");
//        populationGroup = (PopulationGroup) getDao().persist(populationGroup);
//
//        Person person = new Person("Mark", "Ashworth", "MP", "3534345355", new Date(74, 4, 31));
//        person.dateOfBirth(1974, 5, 31);
//        person.setGender(genders[0]);
//        person.setPopulationGroup(populationGroup);
//
//        person = (Person) getDao().persist(person);
//
//        List results = getDao().retrieve(Person.class, DaoMode.XML);
//        for (Object object : results) {
//            if (object instanceof Element) {
//                logger.info("Result {}", ((Element) object).asXML());
//            }
//        }
    }
}
